﻿using System;
using Be.Timvw.Framework.Domain.Ranges;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Be.Timvw.Framework.Domain.Effectivity
{
    /// <summary>
    /// Specifications for the determination of effectivity.
    /// </summary>
    [TestClass]
    public class WhenDeterminingEffectivity
    {
        /// <summary>
        /// Gets an effectivity that is effective throughout the year 2000.
        /// </summary>
        /// <returns></returns>
        private static IEffectivity<string> GetEffectivityForYear2000()
        {
            string name = "me";
            DateTime begin = new DateTime(2000, 1, 1);
            DateTime end = new DateTime(2000, 12, 31);
            IRange<DateTime> validityPeriod = new Range<DateTime>(begin, end);

            return new Effectivity<string>(name, validityPeriod);
        }

        /// <summary>
        /// Should be effective when date is in period.
        /// </summary>
        [TestMethod]
        public void ShouldBeEffectiveWhenDateIsInPeriod()
        {
            IEffectivity<string> effectivity = GetEffectivityForYear2000();
            DateTime validityDate = new DateTime(2000, 1, 1);
            Assert.IsTrue(effectivity.IsEffectiveOn(validityDate));
        }

        /// <summary>
        /// Should not be effective when date is not in period.
        /// </summary>
        [TestMethod]
        public void ShouldNotBeEffectiveWhenDateIsNotInPeriod()
        {
            IEffectivity<string> effectivity = GetEffectivityForYear2000();
            DateTime validityDate = new DateTime(9999, 1, 1);
            Assert.IsFalse(effectivity.IsEffectiveOn(validityDate));
        }
    }
}